package com.qf.boot2203.config;

import com.qf.boot2203.service.TestService;
import com.qf.boot2203.service.impl.TestServiceImplBetter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

/**
 * 配置类的写法
 * 配置类的作用；向IOC容器中添加 bean
 */
@Configuration  // 该注解代表当前类是一个配置类
public class MyConfig {

    @Bean(name = "tsb")
    @Scope("prototype") // 控制bean是多例
    public TestService testServiceBetter(){

        // 自定义创建 对象的过程
        final TestServiceImplBetter testServiceImplBetter = new TestServiceImplBetter();
        return testServiceImplBetter;

    }

}
